<%@page import="java.util.Enumeration"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<%@ taglib uri="http://www.springframework.org/tags" prefix="s"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>

<!DOCTYPE html>
<html lang="en">
<head>
<title><s:message code="app.title" /></title>
<%@ include file="Include.jsp"%>
<script type="text/javascript">
	
	$(document).ready(function() {
		$("#portname").focus();	
		
		$("#sectorid").val("${requestScope.portForm.sectorid}").trigger('change');
		/* $("#contryid").val("${requestScope.portForm.countryid}").trigger('change');
		$("#stateid").val("${requestScope.portForm.stateid}").trigger('change');
		$("#cityid").val("${requestScope.portForm.cityid}").trigger('change'); */
		
	});
	
</script>
</head>
<body>
	<%
		Enumeration requestAttributes = request.getAttributeNames();
	
		while(requestAttributes.hasMoreElements()){
			Object obj = requestAttributes.nextElement();
			System.out.println(obj +"===="+request.getAttribute( (String) obj ));
		}
		
		requestAttributes = request.getSession().getAttributeNames();
		
		System.out.println("================================");
		
		while(requestAttributes.hasMoreElements()){
			Object obj = requestAttributes.nextElement();
			System.out.println(obj +"===="+request.getSession().getAttribute( (String) obj ));
		}
		
	%>
	<div class="container">
		<%@ include file="Menu.jsp"%>
		<h2><s:message code="portForm.editheader" /></h2>
		<hr>
		<form:form id="cancelForm">
		</form:form>
		<form:form class="form-horizontal" method="post" name="portForm" id="portForm" commandName="portForm"
	           modelAttribute="portForm" >
			<form:hidden path="portid" />
			
			<table class="table table-bordered">
			<tr>
				<th width="15%"><form:label path="portname"><s:message code="portForm.portname" /></form:label></th>
				<td width="*">
					<form:input path="portname" cssClass="input-medium" id="portname" maxlength="30" size="30" tabindex="1" />
					<form:errors cssClass="text-error" path="portname" />
				</td>
			</tr>
			<tr>
				<th width="15%"><form:label path="sectorid"><s:message code="app.sector" /></form:label></th>
				<td width="*">
					<form:select path="sectorid" cssClass="input-medium" onchange="renderDependentCombo(this.value,'GetCountryListForSector','countryid','${requestScope.portForm.countryid}');">
						<form:option value="">--SELECT-</form:option>
						<form:options items="${sectorMasterList}" itemLabel="sectorname" itemValue="sectorid"/>
					</form:select>
					<form:errors cssClass="text-error" path="sectorid" />
				</td>
			</tr>
			<tr>
				<th width="15%"><form:label path="countryid"><s:message code="app.country" /></form:label></th>
				<td width="*">
					<form:select path="countryid" cssClass="input-medium" id="countryid" onchange="renderDependentCombo(this.value,'GetStateListForCountry','stateid','${requestScope.portForm.stateid}');">
						<form:option value="">--SELECT-</form:option>
					</form:select>
					<form:errors cssClass="text-error" path="countryid" />
				</td>
			</tr>
			<tr>
				<th width="15%"><form:label path="stateid"><s:message code="app.state" /></form:label></th>
				<td width="*">
					<form:select path="stateid" cssClass="input-medium" id="stateid" onchange="renderDependentCombo(this.value,'GetCityListForState','cityid','${requestScope.portForm.cityid}');">
						<form:option value="">--SELECT-</form:option>
					</form:select>
					<form:errors cssClass="text-error" path="stateid" />
				</td>
			</tr>
			<tr>
				<th width="15%"><form:label path="cityid"><s:message code="app.city" /></form:label></th>
				<td width="*">
					<form:select path="cityid" cssClass="input-medium" id="cityid">
						<form:option value="">--SELECT-</form:option>
					</form:select>
					<form:errors cssClass="text-error" path="cityid" />
				</td>
			</tr>
			<tr>
				<th width="15%"><form:label path="blspclreq"><s:message code="portForm.blspclreq" /></form:label></th>
				<td width="*">
					<form:input path="blspclreq" cssClass="input-xxlarge" id="blspclreq" maxlength="30" size="30" tabindex="1" />
					<form:errors cssClass="text-error" path="blspclreq" />
				</td>
			</tr>
		</table>
		<br>
			<button class="btn btn-primary" type="submit" formaction="EditPort"><s:message code="add.edit" /></button>
			<button class="btn" type="submit" formaction="ListPort" form="cancelForm" formmethod="get"><s:message code="app.cancel" /></button>
		</form:form>
		 <%@ include file="Footer.jsp"%>
	</div>
</body>
</html>